import 'package:flutter/material.dart';

class Testcar extends StatefulWidget {
  const Testcar({Key? key}) : super(key: key);

  @override
  State<Testcar> createState() => _TestcarState();
}

class _TestcarState extends State<Testcar> {
  var topTitle = "";
  var subTitle = "";

  var weekDay = "一";
  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    final now = DateTime.now();

    if (now.weekday == 1) {
      weekDay = "一";
    } else if (now.weekday == 2) {
      weekDay = "二";
    } else if (now.weekday == 3) {
      weekDay = "三";
    } else if (now.weekday == 4) {
      weekDay = "四";
    } else if (now.weekday == 5) {
      weekDay = "五";
    } else if (now.weekday == 6) {
      weekDay = "六";
    } else {
      weekDay = "日";
    }

    this.topTitle = "${now.month}月${now.day}日 周${this.weekDay}";
    this.subTitle = "${now.hour}:${now.minute}";
  }

  Widget leftW() {
    return Row(
      children: [
        IconButton(
          icon: new Icon(Icons.arrow_back_ios),
          iconSize: 25,
          onPressed: () => {},
        ),
        IconButton(
          icon: new Icon(Icons.close),
          iconSize: 30,
          onPressed: () => {},
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false, // 不跟随键盘移动
      backgroundColor: Colors.white,
      appBar: AppBar(
        leading: this.leftW(),
        leadingWidth: 100,
        actions: [
          IconButton(
            icon: new Icon(Icons.share_outlined),
            iconSize: 20,
            onPressed: () => {},
          )
        ],
        title: Title(
          color: Colors.white,
          title: "扫一扫",
          child: Text("扫一扫", style: TextStyle(fontWeight: FontWeight.w800)),
        ),
      ),
      body: Stack(
        children: [
          Image(
            image: AssetImage('assets/images/bottom.png'),
            fit: BoxFit.fill,
            width: double.infinity,
            height: double.infinity,
          ),
          Column(
            children: [
              SizedBox(
                width: 200,
                height: 80,
              ),
              Center(
                child: Text(
                  this.topTitle,
                  style: TextStyle(
                      fontWeight: FontWeight.w500,
                      color: Colors.white,
                      fontSize: 45),
                  textAlign: TextAlign.center,
                ),
              ),
              Center(
                child: Text(
                  this.subTitle,
                  style: TextStyle(
                      fontWeight: FontWeight.w500,
                      color: Colors.white,
                      fontSize: 22),
                  textAlign: TextAlign.center,
                ),
              )
            ],
          )
        ],
      ),
    );
  }
}
